package com.bnyy.medicalHousekeeper.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;

import com.bnyy.common.view.AAChartCoreLib.AAChartCreator.AAChartModel;
import com.bnyy.common.view.AAChartCoreLib.AAChartCreator.AASeriesElement;
import com.bnyy.common.view.AAChartCoreLib.AAChartEnum.AAChartLineDashStyleType;
import com.bnyy.common.view.AAChartCoreLib.AAChartEnum.AAChartStackingType;
import com.bnyy.common.view.AAChartCoreLib.AAChartEnum.AAChartSymbolStyleType;
import com.bnyy.common.view.AAChartCoreLib.AAChartEnum.AAChartSymbolType;
import com.bnyy.common.view.AAChartCoreLib.AAChartEnum.AAChartType;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AAColumnrange;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AACrosshair;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AAMarker;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AAOptions;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AASeries;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AASeriesEvents;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AAStyle;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AATooltip;
import com.bnyy.common.view.AAChartCoreLib.AAOptionsModel.AAYAxis;
import com.bnyy.common.view.AAChartCoreLib.AATools.AAColor;
import com.bnyy.common.view.AAChartCoreLib.AATools.AAGradientColor;
import com.bnyy.common.view.AAChartCoreLib.AATools.AALinearGradientDirection;
import com.bnyy.medicalHousekeeper.R;
import com.bnyy.medicalHousekeeper.base.BaseActivityImpl;
import com.bnyy.medicalHousekeeper.bean.BloodPressDetail;
import com.bnyy.medicalHousekeeper.bean.IndexStats;
import com.bnyy.medicalHousekeeper.fragment.HealthDataDetailFragment;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.gson.Gson;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;

import butterknife.BindView;

/**
 * Author : 关炳鹏
 * Description :
 * Date : 2023/2/9
 **/
public class HealthDataDetailActivity extends BaseActivityImpl {
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tab_layout)
    TabLayout tabLayout;
    @BindView(R.id.view_pager)
    ViewPager2 viewPager;

    public static void show(Context context, int wearId, int type) {
        Intent intent = new Intent(context, HealthDataDetailActivity.class);
        intent.putExtra("wearId", wearId);
        intent.putExtra("type", type);
        context.startActivity(intent);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_health_data_detail;
    }

    @Override
    public String getTitleStr() {
        return null;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStatusBarColor(ContextCompat.getColor(mContext, R.color.green_theme));

        int wearId = getIntent().getIntExtra("wearId", -1);


        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        viewPager.setAdapter(new FragmentStateAdapter(getSupportFragmentManager(), getLifecycle()) {
            @NonNull
            @Override
            public Fragment createFragment(int position) {
                switch (position) { // 0:心率 3:血压 4:血氧
                    case 0:
                        return HealthDataDetailFragment.getInstance(wearId, 3);
                    case 1:
                        return HealthDataDetailFragment.getInstance(wearId, 0);
                    case 2:
                        return HealthDataDetailFragment.getInstance(wearId, 4);
                }
                return null;
            }

            @Override
            public int getItemCount() {
                return 3;
            }
        });

        new TabLayoutMediator(tabLayout, viewPager, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                switch (position) {
                    case 0:
                        tab.setText("血压");
                        break;
                    case 1:
                        tab.setText("心率");
                        break;
                    case 2:
                        tab.setText("血氧");
                        break;
                }
            }
        }).attach();
        int type = getIntent().getIntExtra("type", -1);
        if (type != -1 && type != 3) {
            switch (type) { // 0:心率 3:血压 4:血氧
                case 0:
                    viewPager.setCurrentItem(1);
                    break;
                case 4:
                    viewPager.setCurrentItem(2);
                    break;
            }
        }
    }

}
